# ifndef __RgnProperties_H_
# define __RgnProperties_H_

struct rgn_t;
void ShowRgnProperties (HWND _hWnd, rgn_t & _rgn);
struct find_info_t;
void ShowRgnProperties (HWND _hWnd, const find_info_t & _Selection);

//////////////////////////////////////////////////////////////////////
// INTERNAL USE ONLY.

# include "PropertyPages.h"

enum RgnPP_t {
	ppDontSave = -1,
	ppMain     = 0,
	ppElements = 1,
	ppAddress  = 2,
	ppInfo     = 3,
	ppHWExit   = 4,
	ppRouting  = 5,
	ppSource   = 6,
	ppExtras   = 7
};

class CRgnPPageBase : public CPropertyPages::CPage {
  public:
	CRgnPPageBase (UINT _uiDlgId, RgnPP_t _pp, rgn_t & _rgn) :
		CPropertyPages::CPage (_uiDlgId),
		m_RgnPP (_pp),
		m_rgn (_rgn)
	{}

	// Override.
	virtual void OnActivatePage (const PSHNOTIFY *);

	RgnPP_t GetId () const {return m_RgnPP;}

  protected:
	rgn_t & m_rgn;

	void RefreshRequired ();

  private:
	const RgnPP_t m_RgnPP;
};

class CWptPage : public CRgnPPageBase {
  public:
	CWptPage (rgn_t & _rgn) : CRgnPPageBase (IDD_RGN_WAYPOINT, ppDontSave, _rgn) {}
	 
	// Override.
	virtual bool OnInit (HWND _hwndFocus);
	virtual void OnCommand (WORD _wCmd, WORD _wNotifyCode, HWND _hwndCtl);
	virtual void OnApply (const PSHNOTIFY *);

  private:
	void _FillType ();
};

class CTrackPage : public CRgnPPageBase {
  public:
	CTrackPage (rgn_t & _rgn) : CRgnPPageBase (IDD_RGN_TRACK, ppDontSave, _rgn) {}
	 
	// Override.
	virtual bool OnInit (HWND _hwndFocus);
	virtual void OnCommand (WORD _wCmd, WORD _wNotifyCode, HWND _hwndCtl);
	virtual void OnApply (const PSHNOTIFY *);
};

class CTrackPointsPage : public CRgnPPageBase {
  public:
	CTrackPointsPage (rgn_t & _rgn, size_t _cPoint) :
		CRgnPPageBase (IDD_RGN_TRACKPOINTS, ppDontSave, _rgn),
		m_cPoint (_cPoint)
	{}
	 
	// Override.
	virtual bool OnInit (HWND _hwndFocus);

  private:
	void _FillPoints (HWND _hList);

	const size_t m_cPoint;
};

class CRoutePage : public CRgnPPageBase {
  public:
	CRoutePage (rgn_t & _rgn) : CRgnPPageBase (IDD_RGN_ROUTE, ppDontSave, _rgn), m_hList (NULL) {}
	 
	// Override.
	virtual bool OnInit (HWND _hwndFocus);
	virtual void OnCommand (WORD _wCmd, WORD _wNotifyCode, HWND _hwndCtl);
	virtual bool OnNotify (int _idCtrl, NMHDR * _pInfo);
	virtual void OnApply (const PSHNOTIFY *);

  private:
	void _FillPoints ();

	HWND m_hList;
};

class CRgnPage : public CRgnPPageBase {
  public:
	CRgnPage (rgn_t & _rgn) : CRgnPPageBase (IDD_RGN_PROPERTIES, ppMain, _rgn) {}
	 
	// Override.
	virtual bool OnInit (HWND _hwndFocus);
	virtual void OnCommand (WORD _wCmd, WORD _wNotifyCode, HWND _hwndCtl);
	virtual void OnApply (const PSHNOTIFY *);

  private:
	void _AddSpecialCodeToLabel (const char * _str);
	void _FillType (USHORT _ushType);

	USHORT m_ushType;
};

class CRgnElementsPage : public CRgnPPageBase {
  public:
	CRgnElementsPage (rgn_t & _rgn) : CRgnPPageBase (IDD_RGN_ELEMENTS, ppElements, _rgn), m_hList (NULL) {}
	 
	// Override.
	virtual bool OnInit (HWND _hwndFocus);
	virtual void OnCommand (WORD _wCmd, WORD _wNotifyCode, HWND _hwndCtl);
	virtual bool OnNotify (int _idCtrl, NMHDR * _pInfo);
	virtual void OnApply (const PSHNOTIFY *);

  private:
	void _FillElements ();
	void _RefreshElementsBtns ();
	void _LocateElement (size_t _cElementOrOrigin);

	HWND m_hList;
};

struct city_t;
struct zip_t;
struct highway_t;

class CRgnAddressPage : public CRgnPPageBase {
  public:
	CRgnAddressPage (UINT _uiId, rgn_t & _rgn) : CRgnPPageBase (_uiId, ppAddress, _rgn), m_pCity (NULL), m_pZip (NULL) {}
	 
	// Override.
	virtual bool OnInit (HWND _hwndFocus);
	virtual void OnCommand (WORD _wCmd, WORD _wNotifyCode, HWND _hwndCtl);
	virtual void OnApply (const PSHNOTIFY *);

  private:
	city_t * m_pCity;
	zip_t  * m_pZip;
};

class CRgnInfoPage : public CRgnPPageBase {
  public:
	CRgnInfoPage (UINT _uiId, rgn_t & _rgn) : CRgnPPageBase (_uiId, ppInfo, _rgn) {}
	 
	// Override.
	virtual bool OnInit (HWND _hwndFocus);
	virtual void OnCommand (WORD _wCmd, WORD _wNotifyCode, HWND _hwndCtl);
	virtual void OnApply (const PSHNOTIFY *);
};

class CRgnExitsPage : public CRgnPPageBase {
  public:
	CRgnExitsPage (rgn_t & _rgn) : CRgnPPageBase (IDD_RGN_EXIT, ppHWExit, _rgn), m_pHighway (NULL) {}
	 
	// Override.
	virtual bool OnInit (HWND _hwndFocus);
	virtual void OnCommand (WORD _wCmd, WORD _wNotifyCode, HWND _hwndCtl);
	virtual void OnApply (const PSHNOTIFY *);

  private:
	void _FillHighway (const highway_t * _pHighway);

	highway_t * m_pHighway;
};

class CRgnRoutingPage : public CRgnPPageBase {
  public:
	CRgnRoutingPage (rgn_t & _rgn) : CRgnPPageBase (IDD_RGN_ROUTING, ppRouting, _rgn) {}
	 
	// Override.
	virtual bool OnInit (HWND _hwndFocus);
	virtual void OnCommand (WORD _wCmd, WORD _wNotifyCode, HWND _hwndCtl);
	virtual void OnApply (const PSHNOTIFY *);
};

class CRgnSourcePage : public CRgnPPageBase {
  public:
	CRgnSourcePage (rgn_t & _rgn) : CRgnPPageBase (IDD_RGN_SOURCE, ppSource, _rgn) {}
	 
	// Override.
	virtual bool OnInit (HWND _hwndFocus);
};

class CRgnExtrasPage : public CRgnPPageBase {
  public:
	CRgnExtrasPage (rgn_t & _rgn) : CRgnPPageBase (IDD_RGN_EXTRAS, ppExtras, _rgn) {}
	 
	// Override.
	virtual bool OnInit (HWND _hwndFocus);
	virtual void OnCommand (WORD _wCmd, WORD _wNotifyCode, HWND _hwndCtl);

  private:
	const char * _GetValue (const char * _pKey, const char * _pEnd);
	void _FillExtras (HWND _hList);
};

# endif // __RgnProperties_H_